<template>
  <div>
       <el-table
    :data="replyList"
    :default-sort = "{prop: 'replyNum', order: 'descending'}"
    style="width: 100%">
    <!-- <el-table-column
      label="用户"
      width="180">
        <template slot-scope="scope">
            <img style="width:50px;height:50px" :src="'/api/upload/'+scope.row.userHeader">
      </template>
    </el-table-column> -->
    <el-table-column
      label="用户名"
      width="180"
      prop="userInfoBean.userName"
      >
     
    </el-table-column>
    <el-table-column
      label="评论内容"
      width="180"
      prop="replyContent"
      >
     
    </el-table-column>
    <el-table-column
      label="点赞数"
      width="180"
      prop="replyNum"
      >
     
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">

          <div  @click="like(scope.row)"> 

        <img src="../assets/zan.png" v-show="ifZan(scope.row)"/>  

<!--         <img src="../assets/notzan.png" v-show="ifZan(scope.row)"/>  -->

       

      </div>
          
        <!-- <el-button
          size="mini"
           @click="like(scope.row)">点赞</el-button> -->

        
      </template>
    </el-table-column>
  </el-table>
  




   <!-- <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagination.current"
      :page-sizes="[5,10,15,20]"
      :page-size="pagination.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pagination.total">
    </el-pagination> -->
  </div>
</template>

<script>
import {mapState,mapActions} from 'vuex'
export default {
    data(){
        return{
             downIcon:true
        }
    },
    created(){
        this.showAll()
        this.getUser()
    
    },
    computed:{
            ...mapState("reply",["replyList","sessionUser"])
    },
    methods:{
       
         ...mapActions("reply",["showAll","getUser"]),
       
        async like(replyObj){
            var info = await this.ajax.getSubmit("/api/users/like",{userId:this.sessionUser.userId,replyId:replyObj.replyId})
            if(info == "ok"){
                this.showAll()
            }
         },
        async ifZan(replyObj){
            var info = await this.ajax.getSubmit("/api/users/ifZan",{userId:this.sessionUser.userId,replyId:replyObj.replyId})
            // alert(JSON.stringify(info))
            console.log(JSON.stringify(info))
            return info
        }
         
    }

}
</script>

<style>

</style>